package com.bw.live_streaming.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.bw.live_streaming.entity.SlideshowEntity;
import com.bw.live_streaming.service.SlideshowService;
import com.bw.common.utils.PageUtils;
import com.bw.common.utils.R;



/**
 * 
 *
 * @author wj
 * @email sunlightcs@gmail.com
 * @date 2021-08-18 20:22:42
 */
@RestController
@RequestMapping("live_streaming/slideshow")
public class SlideshowController {
    @Autowired
    private SlideshowService slideshowService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = slideshowService.queryPage(params);

        return R.ok().put("page", page);
    }
    /**
     * 根据点击量进行倒序排序
     */
    @GetMapping("lists")
    public R lists(){
        List<SlideshowEntity> list=slideshowService.lists();
        return R.ok().put("list",list);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{slideshowId}")
    public R info(@PathVariable("slideshowId") Integer slideshowId){
		SlideshowEntity slideshow = slideshowService.getById(slideshowId);

        return R.ok().put("slideshow", slideshow);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SlideshowEntity slideshow){
		slideshowService.save(slideshow);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SlideshowEntity slideshow){
		slideshowService.updateById(slideshow);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] slideshowIds){
		slideshowService.removeByIds(Arrays.asList(slideshowIds));

        return R.ok();
    }

}
